package com.sleep.psy.external_server.business.main.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sleep.psy.external_server.business.main.entity.MainUserType;
import com.sleep.psy.external_server.business.main.mapper.MainUserTypeMapper;
import com.sleep.psy.external_server.business.main.service.MainUserTypeService;
import com.sleep.psy.external_server.constants.MySqlConstant;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 用户分类表 服务实现类
 * </p>
 *
 * @author wenliguo
 * @since 2025-08-12
 */
@Service
public class MainUserTypeServiceImpl extends ServiceImpl<MainUserTypeMapper, MainUserType> implements MainUserTypeService {

    @Autowired
    private MainUserTypeMapper mainUserTypeMapper;


    /**
     * 通过用户id获取用户分类
     * @author wenliguo
     * @date 2025/8/13 11:35
     * @param userId 用户id
     * @return java.util.List<com.sleep.psy.external_server.main.entity.MainUserType>
     */
    @Override
    public List<MainUserType> selectByUserId(Long userId) {
        QueryWrapper<MainUserType> wrapper = new QueryWrapper<>();
        wrapper.like("user_ids", userId)
                .eq("status", MySqlConstant.STATUS_1);
        return mainUserTypeMapper.selectList(wrapper);
    }
}
